import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    name: "Index",
    redirect: '/home',  // 重定向:重新指向其它path,会改变网址
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [
      {
        path: 'shou',
        name: 'Shou',
        component: () => import('../views/home/Shou.vue'),
        meta: {
          title: "首页",
        }
      },
      {
        path: 'classifg',
        name: 'Classifg',
        component: () => import('../views/home/Classifg.vue'),
        meta: {
          title: "分类",
        }
      },
      {
        path: 'shop',
        name: 'Shop',
        component: () => import('../views/home/Shop.vue'),
        meta: {
          title: "购物车",
        }
      },
      {
        path: 'my',
        name: 'My',
        component: () => import('../views/home/My.vue'),
        meta: {
          title: "我的",
        }
      }
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
